<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE BangPatterns, CPP, RecordWildCards #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- Module      : Data.Text.Lazy.IO</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Copyright   : (c) 2009, 2010 Bryan O'Sullivan,</span><span>
</span><span id="line-6"></span><span class="hs-comment">--               (c) 2009 Simon Marlow</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Portability : GHC</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Efficient locale-sensitive support for lazy text I\/O.</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Skip past the synopsis for some important notes on performance and</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- portability across different versions of GHC.</span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Lazy.IO</span><span>
</span><span id="line-17"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-18"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Performance</span></span><span>
</span><span id="line-19"></span><span>    </span><span class="annot"><span class="hs-comment">-- $performance</span></span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Locale support</span></span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-comment">-- $locale</span><span>
</span><span id="line-23"></span><span>    </span><span class="hs-comment">-- * File-at-a-time operations</span><span>
</span><span id="line-24"></span><span>      </span><span class="annot"><a href="Data.Text.Lazy.IO.html#readFile"><span class="hs-identifier">readFile</span></a></span><span>
</span><span id="line-25"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#writeFile"><span class="hs-identifier">writeFile</span></a></span><span>
</span><span id="line-26"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#appendFile"><span class="hs-identifier">appendFile</span></a></span><span>
</span><span id="line-27"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Operations on handles</span></span><span>
</span><span id="line-28"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#hGetContents"><span class="hs-identifier">hGetContents</span></a></span><span>
</span><span id="line-29"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#hGetLine"><span class="hs-identifier">hGetLine</span></a></span><span>
</span><span id="line-30"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#hPutStr"><span class="hs-identifier">hPutStr</span></a></span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#hPutStrLn"><span class="hs-identifier">hPutStrLn</span></a></span><span>
</span><span id="line-32"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Special cases for standard input and output</span></span><span>
</span><span id="line-33"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#interact"><span class="hs-identifier">interact</span></a></span><span>
</span><span id="line-34"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#getContents"><span class="hs-identifier">getContents</span></a></span><span>
</span><span id="line-35"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#getLine"><span class="hs-identifier">getLine</span></a></span><span>
</span><span id="line-36"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#putStr"><span class="hs-identifier">putStr</span></a></span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Lazy.IO.html#putStrLn"><span class="hs-identifier">putStrLn</span></a></span><span>
</span><span id="line-38"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Lazy.html"><span class="hs-identifier">Data.Text.Lazy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier">Text</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/System.IO.html#appendFile"><span class="hs-identifier">appendFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#getContents"><span class="hs-identifier">getContents</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#getLine"><span class="hs-identifier">getLine</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#interact"><span class="hs-identifier">interact</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>                       </span><span class="annot"><a href="../../base/src/System.IO.html#putStr"><span class="hs-identifier">putStr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#putStrLn"><span class="hs-identifier">putStrLn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#readFile"><span class="hs-identifier">readFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#writeFile"><span class="hs-identifier">writeFile</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier">Handle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.IOMode.html#IOMode"><span class="hs-identifier">IOMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Text.html#hPutChar"><span class="hs-identifier">hPutChar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.StdHandles.html#openFile"><span class="hs-identifier">openFile</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.StdHandles.html#stdin"><span class="hs-identifier">stdin</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.StdHandles.html#stdout"><span class="hs-identifier">stdout</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>                  </span><span class="annot"><a href="../../base/src/System.IO.html#withFile"><span class="hs-identifier">withFile</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Data.Text.IO.html"><span class="hs-identifier">Data.Text.IO</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">T</span></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Data.Text.Lazy.html"><span class="hs-identifier">Data.Text.Lazy</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">L</span></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">E</span></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier">when</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.IORef.html#"><span class="hs-identifier">Data.IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier">readIORef</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.IO.html"><span class="hs-identifier">Data.Text.Internal.IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.IO.html#hGetLineWith"><span class="hs-identifier">hGetLineWith</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.IO.html#readChunk"><span class="hs-identifier">readChunk</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html"><span class="hs-identifier">Data.Text.Internal.Lazy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Lazy.html#chunk"><span class="hs-identifier">chunk</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#empty"><span class="hs-identifier">empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#"><span class="hs-identifier">GHC.IO.Buffer</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Buffer.html#isEmptyBuffer"><span class="hs-identifier">isEmptyBuffer</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#"><span class="hs-identifier">GHC.IO.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOException"><span class="hs-identifier">IOException</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOErrorType"><span class="hs-identifier">IOErrorType</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#ioException"><span class="hs-identifier">ioException</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#"><span class="hs-identifier">GHC.IO.Handle.Internals</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#augmentIOError"><span class="hs-identifier">augmentIOError</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#hClose_help"><span class="hs-identifier">hClose_help</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-55"></span><span>                                </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#wantReadableHandle"><span class="hs-identifier">wantReadableHandle</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Internals.html#withHandle"><span class="hs-identifier">withHandle</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#"><span class="hs-identifier">GHC.IO.Handle.Types</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier">Handle__</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#HandleType"><span class="hs-identifier">HandleType</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#BufferMode"><span class="hs-identifier">BufferMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.html#hGetBuffering"><span class="hs-identifier">hGetBuffering</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.html#hSetBuffering"><span class="hs-identifier">hSetBuffering</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Error.html#"><span class="hs-identifier">System.IO.Error</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/System.IO.Error.html#isEOFError"><span class="hs-identifier">isEOFError</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.Unsafe.html#"><span class="hs-identifier">System.IO.Unsafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Unsafe.html#unsafeInterleaveIO"><span class="hs-identifier">unsafeInterleaveIO</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span class="hs-comment">-- $performance</span><span>
</span><span id="line-62"></span><span class="hs-comment">--</span><span>
</span><span id="line-63"></span><span class="hs-comment">-- The functions in this module obey the runtime system's locale,</span><span>
</span><span id="line-64"></span><span class="hs-comment">-- character set encoding, and line ending conversion settings.</span><span>
</span><span id="line-65"></span><span class="hs-comment">--</span><span>
</span><span id="line-66"></span><span class="hs-comment">-- If you know in advance that you will be working with data that has</span><span>
</span><span id="line-67"></span><span class="hs-comment">-- a specific encoding (e.g. UTF-8), and your application is highly</span><span>
</span><span id="line-68"></span><span class="hs-comment">-- performance sensitive, you may find that it is faster to perform</span><span>
</span><span id="line-69"></span><span class="hs-comment">-- I\/O with bytestrings and to encode and decode yourself than to use</span><span>
</span><span id="line-70"></span><span class="hs-comment">-- the functions in this module.</span><span>
</span><span id="line-71"></span><span class="hs-comment">--</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- Whether this will hold depends on the version of GHC you are using,</span><span>
</span><span id="line-73"></span><span class="hs-comment">-- the platform you are working on, the data you are working with, and</span><span>
</span><span id="line-74"></span><span class="hs-comment">-- the encodings you are using, so be sure to test for yourself.</span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span class="hs-comment">-- | Read a file and return its contents as a string.  The file is</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- read lazily, as with 'getContents'.</span><span>
</span><span id="line-78"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#readFile"><span class="hs-identifier hs-type">readFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-79"></span><span id="readFile"><span class="annot"><span class="annottext">readFile :: FilePath -&gt; IO Text
</span><a href="Data.Text.Lazy.IO.html#readFile"><span class="hs-identifier hs-var hs-var">readFile</span></a></span></span><span> </span><span id="local-6989586621679116200"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679116200"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; IO Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#openFile"><span class="hs-identifier hs-var">openFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679116200"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier hs-var">ReadMode</span></a></span><span> </span><span class="annot"><span class="annottext">IO Handle -&gt; (Handle -&gt; IO Text) -&gt; IO Text
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Text
</span><a href="Data.Text.Lazy.IO.html#hGetContents"><span class="hs-identifier hs-var">hGetContents</span></a></span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="hs-comment">-- | Write a string to a file.  The file is truncated to zero length</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- before writing begins.</span><span>
</span><span id="line-83"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#writeFile"><span class="hs-identifier hs-type">writeFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-84"></span><span id="writeFile"><span class="annot"><span class="annottext">writeFile :: FilePath -&gt; Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#writeFile"><span class="hs-identifier hs-var hs-var">writeFile</span></a></span></span><span> </span><span id="local-6989586621679116198"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679116198"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; (Handle -&gt; IO ()) -&gt; IO ()
forall r. FilePath -&gt; IOMode -&gt; (Handle -&gt; IO r) -&gt; IO r
</span><a href="../../base/src/System.IO.html#withFile"><span class="hs-identifier hs-var">withFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679116198"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#WriteMode"><span class="hs-identifier hs-var">WriteMode</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle -&gt; IO ()) -&gt; IO ())
-&gt; (Text -&gt; Handle -&gt; IO ()) -&gt; Text -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Handle -&gt; Text -&gt; IO ()) -&gt; Text -&gt; Handle -&gt; IO ()
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="hs-comment">-- | Write a string the end of a file.</span><span>
</span><span id="line-87"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#appendFile"><span class="hs-identifier hs-type">appendFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span id="appendFile"><span class="annot"><span class="annottext">appendFile :: FilePath -&gt; Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#appendFile"><span class="hs-identifier hs-var hs-var">appendFile</span></a></span></span><span> </span><span id="local-6989586621679116194"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679116194"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IOMode -&gt; (Handle -&gt; IO ()) -&gt; IO ()
forall r. FilePath -&gt; IOMode -&gt; (Handle -&gt; IO r) -&gt; IO r
</span><a href="../../base/src/System.IO.html#withFile"><span class="hs-identifier hs-var">withFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679116194"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#AppendMode"><span class="hs-identifier hs-var">AppendMode</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle -&gt; IO ()) -&gt; IO ())
-&gt; (Text -&gt; Handle -&gt; IO ()) -&gt; Text -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Handle -&gt; Text -&gt; IO ()) -&gt; Text -&gt; Handle -&gt; IO ()
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span>
</span><span id="line-89"></span><span>
</span><span id="line-90"></span><span class="hs-comment">-- | Lazily read the remaining contents of a 'Handle'.  The 'Handle'</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- will be closed after the read completes, or on error.</span><span>
</span><span id="line-92"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#hGetContents"><span class="hs-identifier hs-type">hGetContents</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-93"></span><span id="hGetContents"><span class="annot"><span class="annottext">hGetContents :: Handle -&gt; IO Text
</span><a href="Data.Text.Lazy.IO.html#hGetContents"><span class="hs-identifier hs-var hs-var">hGetContents</span></a></span></span><span> </span><span id="local-6989586621679116192"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116192"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-94"></span><span>  </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#chooseGoodBuffering"><span class="hs-identifier hs-var">chooseGoodBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116192"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-95"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO (Handle__, Text)) -&gt; IO Text
forall a.
FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO (Handle__, a)) -&gt; IO a
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#wantReadableHandle"><span class="hs-identifier hs-var">wantReadableHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetContents&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116192"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO (Handle__, Text)) -&gt; IO Text)
-&gt; (Handle__ -&gt; IO (Handle__, Text)) -&gt; IO Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679116190"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116190"><span class="hs-identifier hs-var">hh</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-96"></span><span>    </span><span id="local-6989586621679116189"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679116189"><span class="hs-identifier hs-var">ts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Text
</span><a href="Data.Text.Lazy.IO.html#lazyRead"><span class="hs-identifier hs-var">lazyRead</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116192"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-97"></span><span>    </span><span class="annot"><span class="annottext">(Handle__, Text) -&gt; IO (Handle__, Text)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116190"><span class="hs-identifier hs-var">hh</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">haType :: HandleType
</span><a href="../../base/src/GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var">haType</span></a></span><span class="hs-glyph">=</span><span class="annot"><span class="annottext">HandleType
</span><a href="../../base/src/GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679116189"><span class="hs-identifier hs-var">ts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-comment">-- | Use a more efficient buffer size if we're reading in</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- block-buffered mode with the default buffer size.</span><span>
</span><span id="line-101"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#chooseGoodBuffering"><span class="hs-identifier hs-type">chooseGoodBuffering</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span id="chooseGoodBuffering"><span class="annot"><span class="annottext">chooseGoodBuffering :: Handle -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#chooseGoodBuffering"><span class="hs-identifier hs-var hs-var">chooseGoodBuffering</span></a></span></span><span> </span><span id="local-6989586621679116185"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116185"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-103"></span><span>  </span><span id="local-6989586621679116184"><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679116184"><span class="hs-identifier hs-var">bufMode</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO BufferMode
</span><a href="../../base/src/GHC.IO.Handle.html#hGetBuffering"><span class="hs-identifier hs-var">hGetBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116185"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-104"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BufferMode
</span><a href="#local-6989586621679116184"><span class="hs-identifier hs-var">bufMode</span></a></span><span> </span><span class="annot"><span class="annottext">BufferMode -&gt; BufferMode -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; BufferMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#BlockBuffering"><span class="hs-identifier hs-var">BlockBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-105"></span><span>    </span><span class="annot"><span class="annottext">Handle -&gt; BufferMode -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetBuffering"><span class="hs-identifier hs-var">hSetBuffering</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116185"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Int -&gt; BufferMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#BlockBuffering"><span class="hs-identifier hs-var">BlockBuffering</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Maybe Int
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">16384</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span>
</span><span id="line-107"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#lazyRead"><span class="hs-identifier hs-type">lazyRead</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-108"></span><span id="lazyRead"><span class="annot"><span class="annottext">lazyRead :: Handle -&gt; IO Text
</span><a href="Data.Text.Lazy.IO.html#lazyRead"><span class="hs-identifier hs-var hs-var">lazyRead</span></a></span></span><span> </span><span id="local-6989586621679116182"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116182"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO Text -&gt; IO Text
forall a. IO a -&gt; IO a
</span><a href="../../base/src/GHC.IO.Unsafe.html#unsafeInterleaveIO"><span class="hs-identifier hs-var">unsafeInterleaveIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO Text -&gt; IO Text) -&gt; IO Text -&gt; IO Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-109"></span><span>  </span><span class="annot"><span class="annottext">FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO (Handle__, Text)) -&gt; IO Text
forall a.
FilePath -&gt; Handle -&gt; (Handle__ -&gt; IO (Handle__, a)) -&gt; IO a
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#withHandle"><span class="hs-identifier hs-var">withHandle</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetContents&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116182"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__ -&gt; IO (Handle__, Text)) -&gt; IO Text)
-&gt; (Handle__ -&gt; IO (Handle__, Text)) -&gt; IO Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679116181"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116181"><span class="hs-identifier hs-var">hh</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-110"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; HandleType
</span><a href="../../base/src/GHC.IO.Handle.Types.html#haType"><span class="hs-identifier hs-var hs-var">haType</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116181"><span class="hs-identifier hs-var">hh</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-111"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="../../base/src/GHC.IO.Handle.Types.html#ClosedHandle"><span class="hs-identifier hs-var">ClosedHandle</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Handle__, Text) -&gt; IO (Handle__, Text)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116181"><span class="hs-identifier hs-var">hh</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="Data.Text.Internal.Lazy.html#empty"><span class="hs-identifier hs-var">L.empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-112"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><a href="../../base/src/GHC.IO.Handle.Types.html#SemiClosedHandle"><span class="hs-identifier hs-var">SemiClosedHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Handle__ -&gt; IO (Handle__, Text)
</span><a href="Data.Text.Lazy.IO.html#lazyReadBuffered"><span class="hs-identifier hs-var">lazyReadBuffered</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116182"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116181"><span class="hs-identifier hs-var">hh</span></a></span><span>
</span><span id="line-113"></span><span>      </span><span class="annot"><span class="annottext">HandleType
</span><span class="hs-identifier">_</span></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO (Handle__, Text)
forall a. IOException -&gt; IO a
</span><a href="../../base/src/GHC.IO.Exception.html#ioException"><span class="hs-identifier hs-var">ioException</span></a></span><span>
</span><span id="line-114"></span><span>                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe Handle
-&gt; IOErrorType
-&gt; FilePath
-&gt; FilePath
-&gt; Maybe CInt
-&gt; Maybe FilePath
-&gt; IOException
</span><a href="../../base/src/GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-var">IOError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; Maybe Handle
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116182"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IOErrorType
</span><a href="../../base/src/GHC.IO.Exception.html#IllegalOperation"><span class="hs-identifier hs-var">IllegalOperation</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetContents&quot;</span></span><span>
</span><span id="line-115"></span><span>                           </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;illegal handle type&quot;</span></span><span> </span><span class="annot"><span class="annottext">Maybe CInt
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe FilePath
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-116"></span><span>
</span><span id="line-117"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#lazyReadBuffered"><span class="hs-identifier hs-type">lazyReadBuffered</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span id="lazyReadBuffered"><span class="annot"><span class="annottext">lazyReadBuffered :: Handle -&gt; Handle__ -&gt; IO (Handle__, Text)
</span><a href="Data.Text.Lazy.IO.html#lazyReadBuffered"><span class="hs-identifier hs-var hs-var">lazyReadBuffered</span></a></span></span><span> </span><span id="local-6989586621679116176"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116176"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679116175"><span class="annot"><span class="annottext">hh :: Handle__
</span><a href="#local-6989586621679116175"><span class="hs-identifier hs-var">hh</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle__"><span class="hs-identifier hs-type">Handle__</span></a></span><span class="hs-special">{</span><span id="local-6989586621679116148"><span id="local-6989586621679116149"><span id="local-6989586621679116150"><span id="local-6989586621679116151"><span id="local-6989586621679116152"><span id="local-6989586621679116153"><span id="local-6989586621679116154"><span id="local-6989586621679116155"><span id="local-6989586621679116156"><span id="local-6989586621679116157"><span id="local-6989586621679116158"><span id="local-6989586621679116159"><span id="local-6989586621679116160"><span class="annot"><span class="annottext">dev
Maybe TextEncoding
Maybe (TextEncoder enc_state)
Maybe (TextDecoder dec_state)
Maybe (MVar Handle__)
Newline
HandleType
BufferMode
IORef (dec_state, Buffer Word8)
IORef (BufferList CharBufElem)
IORef (Buffer CharBufElem)
IORef (Buffer Word8)
haBufferMode :: Handle__ -&gt; BufferMode
haBuffers :: Handle__ -&gt; IORef (BufferList CharBufElem)
haByteBuffer :: Handle__ -&gt; IORef (Buffer Word8)
haCharBuffer :: Handle__ -&gt; IORef (Buffer CharBufElem)
haCodec :: Handle__ -&gt; Maybe TextEncoding
haDecoder :: ()
haDevice :: ()
haEncoder :: ()
haInputNL :: Handle__ -&gt; Newline
haLastDecode :: ()
haOtherSide :: Handle__ -&gt; Maybe (MVar Handle__)
haOutputNL :: Handle__ -&gt; Newline
haOtherSide :: Maybe (MVar Handle__)
haOutputNL :: Newline
haInputNL :: Newline
haCodec :: Maybe TextEncoding
haDecoder :: Maybe (TextDecoder dec_state)
haEncoder :: Maybe (TextEncoder enc_state)
haBuffers :: IORef (BufferList CharBufElem)
haCharBuffer :: IORef (Buffer CharBufElem)
haLastDecode :: IORef (dec_state, Buffer Word8)
haBufferMode :: BufferMode
haByteBuffer :: IORef (Buffer Word8)
haType :: HandleType
haDevice :: dev
haType :: Handle__ -&gt; HandleType
</span><a href="../../base/src/GHC.IO.Handle.Types.html#haBufferMode"><span class="hs-glyph hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">..</span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-119"></span><span>   </span><span id="local-6989586621679116135"><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679116135"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem) -&gt; IO (Buffer CharBufElem)
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Buffer CharBufElem)
</span><a href="#local-6989586621679116155"><span class="hs-identifier hs-var">haCharBuffer</span></a></span><span>
</span><span id="line-120"></span><span>   </span><span class="hs-special">(</span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679116134"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679116134"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; Buffer CharBufElem -&gt; IO Text
</span><a href="Data.Text.Internal.IO.html#readChunk"><span class="hs-identifier hs-var">readChunk</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116175"><span class="hs-identifier hs-var">hh</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679116135"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-121"></span><span>       </span><span id="local-6989586621679116133"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679116133"><span class="hs-identifier hs-var">ts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Text
</span><a href="Data.Text.Lazy.IO.html#lazyRead"><span class="hs-identifier hs-var">lazyRead</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116176"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-122"></span><span>       </span><span class="annot"><span class="annottext">(Handle__, Text) -&gt; IO (Handle__, Text)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116175"><span class="hs-identifier hs-var">hh</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Text -&gt; Text -&gt; Text
</span><a href="Data.Text.Internal.Lazy.html#chunk"><span class="hs-identifier hs-var">chunk</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679116134"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679116133"><span class="hs-identifier hs-var">ts</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO (Handle__, Text)
-&gt; (IOException -&gt; IO (Handle__, Text)) -&gt; IO (Handle__, Text)
forall e a. Exception e =&gt; IO a -&gt; (e -&gt; IO a) -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#catch"><span class="hs-operator hs-var">`E.catch`</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679116131"><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679116131"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-123"></span><span>         </span><span class="hs-special">(</span><span id="local-6989586621679116130"><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116130"><span class="hs-identifier hs-var">hh'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe SomeException
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle__ -&gt; IO (Handle__, Maybe SomeException)
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#hClose_help"><span class="hs-identifier hs-var">hClose_help</span></a></span><span> </span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116175"><span class="hs-identifier hs-var">hh</span></a></span><span>
</span><span id="line-124"></span><span>         </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; Bool
</span><a href="../../base/src/System.IO.Error.html#isEOFError"><span class="hs-identifier hs-var">isEOFError</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679116131"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-125"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">(Handle__, Text) -&gt; IO (Handle__, Text)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">((Handle__, Text) -&gt; IO (Handle__, Text))
-&gt; (Handle__, Text) -&gt; IO (Handle__, Text)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem -&gt; Bool
forall e. Buffer e -&gt; Bool
</span><a href="../../base/src/GHC.IO.Buffer.html#isEmptyBuffer"><span class="hs-identifier hs-var">isEmptyBuffer</span></a></span><span> </span><span class="annot"><span class="annottext">Buffer CharBufElem
</span><a href="#local-6989586621679116135"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-126"></span><span>                         </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116130"><span class="hs-identifier hs-var">hh'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="Data.Text.Internal.Lazy.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-127"></span><span>                         </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle__
</span><a href="#local-6989586621679116130"><span class="hs-identifier hs-var">hh'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CharBufElem -&gt; Text
</span><a href="Data.Text.Lazy.html#singleton"><span class="hs-identifier hs-var">L.singleton</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\r'</span></span><span class="hs-special">)</span><span>
</span><span id="line-128"></span><span>           </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">IOException -&gt; IO (Handle__, Text)
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#throwIO"><span class="hs-identifier hs-var">E.throwIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOException -&gt; FilePath -&gt; Handle -&gt; IOException
</span><a href="../../base/src/GHC.IO.Handle.Internals.html#augmentIOError"><span class="hs-identifier hs-var">augmentIOError</span></a></span><span> </span><span class="annot"><span class="annottext">IOException
</span><a href="#local-6989586621679116131"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><span class="hs-string">&quot;hGetContents&quot;</span></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116176"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span class="hs-comment">-- | Read a single line from a handle.</span><span>
</span><span id="line-131"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#hGetLine"><span class="hs-identifier hs-type">hGetLine</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-132"></span><span id="hGetLine"><span class="annot"><span class="annottext">hGetLine :: Handle -&gt; IO Text
</span><a href="Data.Text.Lazy.IO.html#hGetLine"><span class="hs-identifier hs-var hs-var">hGetLine</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Text] -&gt; Text) -&gt; Handle -&gt; IO Text
forall t. ([Text] -&gt; t) -&gt; Handle -&gt; IO t
</span><a href="Data.Text.Internal.IO.html#hGetLineWith"><span class="hs-identifier hs-var">hGetLineWith</span></a></span><span> </span><span class="annot"><span class="annottext">[Text] -&gt; Text
</span><a href="Data.Text.Lazy.html#fromChunks"><span class="hs-identifier hs-var">L.fromChunks</span></a></span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="hs-comment">-- | Write a string to a handle.</span><span>
</span><span id="line-135"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#hPutStr"><span class="hs-identifier hs-type">hPutStr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-136"></span><span id="hPutStr"><span class="annot"><span class="annottext">hPutStr :: Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#hPutStr"><span class="hs-identifier hs-var hs-var">hPutStr</span></a></span></span><span> </span><span id="local-6989586621679116126"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116126"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Text -&gt; IO ()) -&gt; [Text] -&gt; IO ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.IO.html#hPutStr"><span class="hs-identifier hs-var">T.hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116126"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Text] -&gt; IO ()) -&gt; (Text -&gt; [Text]) -&gt; Text -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Text -&gt; [Text]
</span><a href="Data.Text.Lazy.html#toChunks"><span class="hs-identifier hs-var">L.toChunks</span></a></span><span>
</span><span id="line-137"></span><span>
</span><span id="line-138"></span><span class="hs-comment">-- | Write a string to a handle, followed by a newline.</span><span>
</span><span id="line-139"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#hPutStrLn"><span class="hs-identifier hs-type">hPutStrLn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-140"></span><span id="hPutStrLn"><span class="annot"><span class="annottext">hPutStrLn :: Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#hPutStrLn"><span class="hs-identifier hs-var hs-var">hPutStrLn</span></a></span></span><span> </span><span id="local-6989586621679116122"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116122"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679116121"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679116121"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116122"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679116121"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; CharBufElem -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutChar"><span class="hs-identifier hs-var">hPutChar</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679116122"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">CharBufElem
</span><span class="hs-char">'\n'</span></span><span>
</span><span id="line-141"></span><span>
</span><span id="line-142"></span><span class="hs-comment">-- | The 'interact' function takes a function of type @Text -&gt; Text@</span><span>
</span><span id="line-143"></span><span class="hs-comment">-- as its argument. The entire input from the standard input device is</span><span>
</span><span id="line-144"></span><span class="hs-comment">-- passed (lazily) to this function as its argument, and the resulting</span><span>
</span><span id="line-145"></span><span class="hs-comment">-- string is output on the standard output device.</span><span>
</span><span id="line-146"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#interact"><span class="hs-identifier hs-type">interact</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-147"></span><span id="interact"><span class="annot"><span class="annottext">interact :: (Text -&gt; Text) -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#interact"><span class="hs-identifier hs-var hs-var">interact</span></a></span></span><span> </span><span id="local-6989586621679116120"><span class="annot"><span class="annottext">Text -&gt; Text
</span><a href="#local-6989586621679116120"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#putStr"><span class="hs-identifier hs-var">putStr</span></a></span><span> </span><span class="annot"><span class="annottext">(Text -&gt; IO ()) -&gt; (Text -&gt; Text) -&gt; Text -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Text -&gt; Text
</span><a href="#local-6989586621679116120"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(Text -&gt; IO ()) -&gt; IO Text -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">IO Text
</span><a href="Data.Text.Lazy.IO.html#getContents"><span class="hs-identifier hs-var">getContents</span></a></span><span>
</span><span id="line-148"></span><span>
</span><span id="line-149"></span><span class="hs-comment">-- | Lazily read all user input on 'stdin' as a single string.</span><span>
</span><span id="line-150"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#getContents"><span class="hs-identifier hs-type">getContents</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-151"></span><span id="getContents"><span class="annot"><span class="annottext">getContents :: IO Text
</span><a href="Data.Text.Lazy.IO.html#getContents"><span class="hs-identifier hs-var hs-var">getContents</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Text
</span><a href="Data.Text.Lazy.IO.html#hGetContents"><span class="hs-identifier hs-var">hGetContents</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdin"><span class="hs-identifier hs-var">stdin</span></a></span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="hs-comment">-- | Read a single line of user input from 'stdin'.</span><span>
</span><span id="line-154"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#getLine"><span class="hs-identifier hs-type">getLine</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-155"></span><span id="getLine"><span class="annot"><span class="annottext">getLine :: IO Text
</span><a href="Data.Text.Lazy.IO.html#getLine"><span class="hs-identifier hs-var hs-var">getLine</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO Text
</span><a href="Data.Text.Lazy.IO.html#hGetLine"><span class="hs-identifier hs-var">hGetLine</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdin"><span class="hs-identifier hs-var">stdin</span></a></span><span>
</span><span id="line-156"></span><span>
</span><span id="line-157"></span><span class="hs-comment">-- | Write a string to 'stdout'.</span><span>
</span><span id="line-158"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#putStr"><span class="hs-identifier hs-type">putStr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-159"></span><span id="putStr"><span class="annot"><span class="annottext">putStr :: Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#putStr"><span class="hs-identifier hs-var hs-var">putStr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#hPutStr"><span class="hs-identifier hs-var">hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdout"><span class="hs-identifier hs-var">stdout</span></a></span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span class="hs-comment">-- | Write a string to 'stdout', followed by a newline.</span><span>
</span><span id="line-162"></span><span class="annot"><a href="Data.Text.Lazy.IO.html#putStrLn"><span class="hs-identifier hs-type">putStrLn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-163"></span><span id="putStrLn"><span class="annot"><span class="annottext">putStrLn :: Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#putStrLn"><span class="hs-identifier hs-var hs-var">putStrLn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Text -&gt; IO ()
</span><a href="Data.Text.Lazy.IO.html#hPutStrLn"><span class="hs-identifier hs-var">hPutStrLn</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#stdout"><span class="hs-identifier hs-var">stdout</span></a></span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span class="hs-comment">-- $locale</span><span>
</span><span id="line-166"></span><span class="hs-comment">--</span><span>
</span><span id="line-167"></span><span class="hs-comment">-- /Note/: The behaviour of functions in this module depends on the</span><span>
</span><span id="line-168"></span><span class="hs-comment">-- version of GHC you are using.</span><span>
</span><span id="line-169"></span><span class="hs-comment">--</span><span>
</span><span id="line-170"></span><span class="hs-comment">-- Beginning with GHC 6.12, text I\/O is performed using the system or</span><span>
</span><span id="line-171"></span><span class="hs-comment">-- handle's current locale and line ending conventions.</span><span>
</span><span id="line-172"></span><span class="hs-comment">--</span><span>
</span><span id="line-173"></span><span class="hs-comment">-- Under GHC 6.10 and earlier, the system I\/O libraries /do not</span><span>
</span><span id="line-174"></span><span class="hs-comment">-- support/ locale-sensitive I\/O or line ending conversion.  On these</span><span>
</span><span id="line-175"></span><span class="hs-comment">-- versions of GHC, functions in this library all use UTF-8.  What</span><span>
</span><span id="line-176"></span><span class="hs-comment">-- does this mean in practice?</span><span>
</span><span id="line-177"></span><span class="hs-comment">--</span><span>
</span><span id="line-178"></span><span class="hs-comment">-- * All data that is read will be decoded as UTF-8.</span><span>
</span><span id="line-179"></span><span class="hs-comment">--</span><span>
</span><span id="line-180"></span><span class="hs-comment">-- * Before data is written, it is first encoded as UTF-8.</span><span>
</span><span id="line-181"></span><span class="hs-comment">--</span><span>
</span><span id="line-182"></span><span class="hs-comment">-- * On both reading and writing, the platform's native newline</span><span>
</span><span id="line-183"></span><span class="hs-comment">--   conversion is performed.</span><span>
</span><span id="line-184"></span><span class="hs-comment">--</span><span>
</span><span id="line-185"></span><span class="hs-comment">-- If you must use a non-UTF-8 locale on an older version of GHC, you</span><span>
</span><span id="line-186"></span><span class="hs-comment">-- will have to perform the transcoding yourself, e.g. as follows:</span><span>
</span><span id="line-187"></span><span class="hs-comment">--</span><span>
</span><span id="line-188"></span><span class="hs-comment">-- &gt; import qualified Data.ByteString.Lazy as B</span><span>
</span><span id="line-189"></span><span class="hs-comment">-- &gt; import Data.Text.Lazy (Text)</span><span>
</span><span id="line-190"></span><span class="hs-comment">-- &gt; import Data.Text.Lazy.Encoding (encodeUtf16)</span><span>
</span><span id="line-191"></span><span class="hs-comment">-- &gt;</span><span>
</span><span id="line-192"></span><span class="hs-comment">-- &gt; putStr_Utf16LE :: Text -&gt; IO ()</span><span>
</span><span id="line-193"></span><span class="hs-comment">-- &gt; putStr_Utf16LE t = B.putStr (encodeUtf16LE t)</span><span>
</span><span id="line-194"></span></pre></body></html>